﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using System.Data.OleDb;

namespace Web_HengliSeed.BLL
{
    public class BaseOrder
    {        /// <summary>
        /// 分页查询订单信息
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageCount"></param>
        /// <returns></returns>
        public static DataTable GetAllOrderInfo(int PageIndex, int PageSize, out int PageCount, out int RecordCount)
        {
            try
            {
                string strSql = " SELECT * FROM T_BaseOrder ";
                string strShow = " * ";
                return ClassFile.AccessHelper.ExecutePager(PageIndex, PageSize, "T_OrderID", strShow, strSql, "", " T_OrderFlag DESC,T_OrderID DESC ", out PageCount, out RecordCount);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 删除指定的订单
        /// </summary>
        /// <param name="strAllLID"></param>
        /// <returns></returns>
        public static bool DelOrderInfo(string strAllLID)
        {
            try
            {
                return ClassFile.AccessHelper.ExecuteNonQuery(ClassFile.AccessHelper.ConnectionString, " DELETE FROM T_BaseOrder WHERE T_OrderID IN(" + strAllLID + ")", null) > 0 ? true : false;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 处理指定的订单
        /// </summary>
        /// <param name="strAllLID"></param>
        /// <returns></returns>
        public static bool UpdateOrderInfo(string strAllLID)
        {
            try
            {
                return ClassFile.AccessHelper.ExecuteNonQuery(ClassFile.AccessHelper.ConnectionString, "  UPDATE T_BaseOrder SET T_OrderFlag=1 WHERE T_OrderID IN(" + strAllLID + ")", null) > 0 ? true : false;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 写订单信息
        /// </summary>
        /// <param name="strNote"></param>
        /// <param name="logClass"></param>
        /// <returns></returns>
        public static bool AddSysOrder(string T_OrderMan, string T_OrderTitle, string T_OrderCount, string T_OrderLink, string Remark)
        {
            try
            {
                OleDbParameter[] parm = { new OleDbParameter("@T_OrderMan",T_OrderMan),
                                                           new OleDbParameter("@T_OrderTitle",T_OrderTitle),
                                                           new OleDbParameter("@T_OrderCount",T_OrderCount),
                                                           new OleDbParameter("@T_OrderLink",T_OrderLink),
                                                           new OleDbParameter("@Remark",Remark),
                                                           new OleDbParameter("@T_DateTime",DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))};
                return (ClassFile.AccessHelper.ExecuteNonQuery(ClassFile.AccessHelper.ConnectionString, " INSERT INTO T_BaseOrder(T_OrderMan,T_OrderTitle,T_OrderCount,T_OrderLink,Remark,T_DateTime) VALUES(@T_OrderMan,@T_OrderTitle,@T_OrderCount,@T_OrderLink,@Remark,@T_DateTime)", parm) > 0) ? true : false;
            }
            catch (Exception EX)
            {
                throw EX;
            }
        }
    }
}
